
import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

public class SomeOtherThread {
	public static void main(String[] args) throws IOException {
		File file = new File("E:/huangbiao/");
		if (!file.exists()) {
			file.mkdirs();
		}

		
		OutputStream in1 = new FileOutputStream(new File("E:/huangbiao.zip"));
		ZipOutputStream zip1 = new ZipOutputStream(in1);
		int d1 = 0;
		if (file.isDirectory()) {
			String[] f = file.list();
			File[] f2 = file.listFiles();
			for (int i = 0; i < f.length; i++) {

				zip1.putNextEntry(new ZipEntry(f[i]));

				BufferedInputStream in2 = new BufferedInputStream(new FileInputStream(f2[i]));
				while ((d1 = in2.read()) != -1) {
					zip1.write(d1);
				}
				in2.close();
				zip1.closeEntry();
			}
		} else {
			zip1.putNextEntry(new ZipEntry(file.getAbsolutePath()));
			BufferedInputStream in2 = new BufferedInputStream(new FileInputStream(file));
			int d2 = 0;
			while ((d1 = in2.read()) != -1) {
				zip1.write(d1);
			}
			in2.close();
			zip1.closeEntry();
		}
		zip1.close();

	}

}
